package 线程状态;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * @Author: 李佳芬
 * @Description: 打印时间
 * @DateTime: 2023/3/31 16:50
 **/
public class TestSleep01 implements Runnable{

    @Override
    public void run() {
        Date date = new Date(System.currentTimeMillis());
        try {
            while (true) {
                Thread.sleep(1000);
                System.out.println(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date));
                date = new Date(System.currentTimeMillis());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        TestSleep01 testSleep01 = new TestSleep01();
        new Thread(testSleep01).start();
    }
}
